Transform

Object representing a linear transform in 2D or 3D space.

Transform.clone(transform)
Argument:
Return type:

Transform

Duplicates the transform.

Transform.compose(transformA, transformB)
Arguments:
Return type:

Transform

Composes two transforms of the same dimensionality.

Transform.createFromMatrix2D(matrix, desiredType)
Arguments:
  • matrix (Matrix)

  • desiredType (enum)

Return type:

Transform

Creates a 2D transform directly from a 3x3 matrix representation.

Transform.createFromMatrix3D(matrix, desiredType)
Arguments:
  • matrix (Matrix)

  • desiredType (enum)

Return type:

Transform

Creates a 3D transform directly from a 4x4 matrix representation.

Transform.createHomography2D(matrix)
Argument:
Return type:

Transform

Creates a 2D homography/projective transform.

Transform.createHomography2DFromPoints(srcPoints, dstPoints, margin, iterations)
Arguments:
  • srcPoints (Point)

  • dstPoints (Point)

  • margin (float)

  • iterations (int)

Return type:

Transform

Creates a homography/projective transform from N corresponding point pairs, source and destination points need to be of equal length. If more than 4 points are given an RANSAC estimation of the homography is performed. If either margin or iterations is set to zero all points provided will be used.

Transform.createHomography3D(matrix)
Argument:
Return type:

Transform

Creates a 3D homography/projective transform.

Transform.createIdentity2D()
Return type:

Transform

Creates a new 2D transform with no rotation, scale or translation.

Transform.createIdentity3D()
Return type:

Transform

Creates a new 3D transform with no rotation, scale or translation.

Transform.createReflection2D(line)
Argument:
Return type:

Transform

Creates a 2D rigid transform that is a reflection in the given 2D line.

Transform.createReflection3D(plane)
Argument:
Return type:

Transform

Creates a 3D rigid transform that is a reflection in the given 3D plane.

Transform.createRigid2D(rotation, xTrans, yTrans, origin)
Arguments:
  • rotation (float)

  • xTrans (float)

  • yTrans (float)

  • origin (Point)

Return type:

Transform

Creates a 2D rigid transform with only rotation and translation.

Transform.createRigidAxisAngle3D(axis, rotation, xTrans, yTrans, zTrans, origin)
Arguments:
  • axis (float)

  • rotation (float)

  • xTrans (float)

  • yTrans (float)

  • zTrans (float)

  • origin (Point)

Return type:

Transform

Creates a 3D rigid transform by defining an axis, a rotation around the axis and a translation.

Transform.createRigidEuler3D(rotationOrder, alpha, beta, gamma, xTrans, yTrans, zTrans, origin)
Arguments:
  • rotationOrder (enum)

  • alpha (float)

  • beta (float)

  • gamma (float)

  • xTrans (float)

  • yTrans (float)

  • zTrans (float)

  • origin (Point)

Return type:

Transform

Creates a 3D rigid transform using Euler angles and translation. Rotations are parameterized and applied in the order specified by the rotation order. E.g. using order “XYZ”, the object is first rotated alpha radians around the world x-axis, then beta radians around the world y-axis, and finally gamma radians around the world z-axis. All rotations are according to the right hand rule, positive is clockwise when looking along the direction of the rotation axis.

Transform.createScaling2D(xScale, yScale, origin)
Arguments:
  • xScale (float)

  • yScale (float)

  • origin (Point)

Return type:

Transform

Creates a 2D scaling transform which scales in the x- and y-dimensions.

Transform.createScaling3D(xScale, yScale, zScale, origin)
Arguments:
  • xScale (float)

  • yScale (float)

  • zScale (float)

  • origin (Point)

Return type:

Transform

Creates a 3D scaling transform which scales in the x-, y-, and z-dimensions.

Transform.createSimilarity2D(rotation, scale, xTrans, yTrans, origin)
Arguments:
  • rotation (float)

  • scale (float)

  • xTrans (float)

  • yTrans (float)

  • origin (Point)

Return type:

Transform

Creates a 2D similarity transform with rotation, scale and translation.

Transform.createTranslation2D(xTrans, yTrans)
Arguments:
  • xTrans (float)

  • yTrans (float)

Return type:

Transform

Creates a 2D translational transform.

Transform.createTranslation3D(xTrans, yTrans, zTrans)
Arguments:
  • xTrans (float)

  • yTrans (float)

  • zTrans (float)

Return type:

Transform

Creates a 3D translational transform.

Transform.decomposeHomographyToRigid3D(homography, cameraMatrix)
Arguments:
Return type:

Transform

Decomposes a 2D homography into rigid 3D transformations and plane normals (n). The 3D transformation is the relative camera motion between the two views of the planar surface with normal n.

The projective homography matrix H = g*K*(R-tn^t)*K^-1 is decomposed into the rotation (R), translation (t) and plane normal (n), given the camera matrix (K). Note that R and t is in the start view coordinate system (before the transformation), while n is in the result view coordinate system. No unique solution exist (up to four sets of R,t,n can be returned). Also note that the translation is normalized (only possible to extract the direction)

Transform.decomposeRigid2D(rigidTransform)
Argument:
Return type:

float

Decomposes a 2D rigid transform into rotation and translation components. The transform must not contain a reflection.

Transform.decomposeRigidEuler3D(rigidTransform, rotationOrder)
Arguments:
  • rigidTransform (Transform)

  • rotationOrder (enum)

Return type:

float

Decomposes a 3D rigid transform into Euler angles and translation. Rotations are parameterized and applied in the order specified by the rotation order. E.g. to recreate a transformation decomposed using “ZYX” rotation order, first rotate alpha around the world z-axis, then beta around the world y-axis and finally gamma around the world x-axis. All rotations are according to the right hand rule, positive is clockwise when looking along the direction of the rotation axis. The transform must not contain a reflection.

Transform.decomposeSimilarity2D(similarityTransform)
Argument:
Return type:

float

Decomposes a similarity transform into a rigid transform and a scale factor. The similarity transform can be reconstructed by first scaling and then applying the rigid transformation.

Transform.decomposeSimilarity3D(similarityTransform)
Argument:
Return type:

float

Decomposes a similarity transform into a rigid transform and a scale factor. The similarity transform can be reconstructed by first scaling and then applying the rigid transformation.

Transform.decomposeTranslation2D(translationTransform)
Argument:
Return type:

float

Decomposes a 2D translation transform into translation components.

Transform.decomposeTranslation3D(translationTransform)
Argument:
Return type:

float

Decomposes a 3D translation transform into translation components.

Transform.getMatrix(transform)
Argument:
Return type:

Matrix

Returns the transform matrix.

Transform.getType(transform)
Argument:
Return type:

enum

Returns the transform type

Transform.invert(transform)
Argument:
Return type:

Transform

Returns the inverse transform.

Transform.rotate2D(inputTransform, rotationAngle, rotationCenter)
Arguments:
  • inputTransform (Transform)

  • rotationAngle (float)

  • rotationCenter (Point)

Return type:

Transform

Returns a 2D transform with a counter clockwise rotation appended to the input transform. The rotation center is optional. If not provided, the world origin is used.

Transform.rotateX(inputTransform, rotationAngle, rotationCenter)
Arguments:
  • inputTransform (Transform)

  • rotationAngle (float)

  • rotationCenter (Point)

Return type:

Transform

Returns a 3D transform with a rotation around an axis parallel to the world x-axis appended to the input transform. The rotation center is optional. If not provided, the world origin is used. Positive rotation is according to the right hand rule, clockwise when looking along the direction of the rotation axis.

Transform.rotateY(inputTransform, rotationAngle, rotationCenter)
Arguments:
  • inputTransform (Transform)

  • rotationAngle (float)

  • rotationCenter (Point)

Return type:

Transform

Returns a 3D transform with a rotation around an axis parallel to the world y-axis appended to the input transform. The rotation center is optional. If not provided, the world origin is used. Positive rotation is according to the right hand rule, clockwise when looking along the direction of the rotation axis.

Transform.rotateZ(inputTransform, rotationAngle, rotationCenter)
Arguments:
  • inputTransform (Transform)

  • rotationAngle (float)

  • rotationCenter (Point)

Return type:

Transform

Returns a 3D transform with a rotation around an axis parallel to the world z-axis appended to the input transform. The rotation center is optional. If not provided, the world origin is used. Positive rotation is according to the right hand rule, clockwise when looking along the direction of the rotation axis.

Transform.scale2D(inputTransform, scaleFactor, scaleCenter)
Arguments:
Return type:

Transform

Returns a 2D transform with a scaling appended to the input transform.

Transform.scale3D(inputTransform, scaleFactor, scaleCenter)
Arguments:
Return type:

Transform

Returns a 3D transform with a scaling appended to the input transform.

Transform.to2D(transform3d)
Argument:
Return type:

Transform

Converts a 3D transform to a 2D transform. For 3D transforms of type similarity or simpler, a 2D transform is created which only uses x- and y-translation, scale and the rotation around the z-axis. Affine and homography 3D transforms are not supported, nor similarity transforms that contain a reflection. The created 2D transform applies the part of the 3D transform that transforms the x,y-coordinates and ignores the z-transformation.

Transform.to3D(transform2d)
Argument:
Return type:

Transform

Converts a 2D transform to a 3D transform. The created 3D transform applies the 2D transform to the x,y-coordinates and leaves the z-coordinates unchanged. This holds up to affine transformations. For homographies, the final scaling of the points is applied also to the z-coordinate.

Transform.toString(transform)
Argument:
Return type:

string

Get a string representation of the transform. The matrix representing the transform is written row-wise.

Transform.toType(transform, desiredType)
Arguments:
Return type:

Transform

Returns a copy of the transformation marked as desired type. If the desired type is not general enough to support the actual transformation, nil is returned. The transform itself is not changed. Converting to a more general type always succeeds.

Transform.translate2D(inputTransform, xTrans, yTrans)
Arguments:
  • inputTransform (Transform)

  • xTrans (float)

  • yTrans (float)

Return type:

Transform

Returns a 2D transform with a translation in world coordinates appended to the input transform.

Transform.translate3D(inputTransform, xTrans, yTrans, zTrans)
Arguments:
  • inputTransform (Transform)

  • xTrans (float)

  • yTrans (float)

  • zTrans (float)

Return type:

Transform

Returns a 3D transform with a translation in world coordinates appended to the input transform.